import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom';
import { Router } from './../../config/router.js';
import New1 from './new1/New1.js';
import { function1, function2, ajax as Ajax } from './../../common/common.js';
import { getApi, browser, localStorage, cookie } from './../../utils/utils.js';

import NewMmodule from './new.module.scss';

import { DatePicker } from 'antd';

class New extends Component {

	componentWillMount() {
		console.log(this)

		// 测试函数
		function1();
		function2();

		// GET 调用接口获取数据
		Ajax({
			url: getApi('test'),
			type: 'GET',
			data: {
				data: 'getTestData'
			},
			callback: function(data) {
				console.log('GET', data);
			}
		});
		// POST 调用接口
		Ajax({
			url: getApi('test'),
			type: 'POST',
			data: {
				date: 'postTestData'
			},
			callback: function(data) {
				console.log('POST', data);
			}
		});
		// 打印浏览器相关参数
		console.log('browser.versions', browser.versions);
		console.log('browser.language', browser.language);

		//localStorage
		localStorage.set('key', 'value');
		console.log('localStorage', localStorage.get('key'));

		// cookie
		console.log('cookie', cookie.get('clientId'))
	}
	componentDidMount() {
	}
	componentWillReceiveProps(newProps) {}
	shouldComponentUpdate(newProps, newState) {
		return true;
	}
	componentWillUpdate(nextProps, nextState) {}
	componentDidUpdate(prevProps, prevState) {}
	componentWillUnmount() {}

	render() {
		return (
			<div className={NewMmodule['New']}>
				New
				<br />
				<DatePicker />
				<Switch>
					<Route path={ Router.client.new.new1.path } component={ New1 }/>
				</Switch>
			</div>
		);
	}
}

export default New;